/* 
  在main.js 进行了以下配置 request.js 就不需要再使用了
  import axios from 'axios'
  axios.defaults.baseURL = 'http://127.0.0.1:3001/'
  axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
  })
  Vue.prototype.$http = axios
*/

// 已弃用
import axios from 'axios'
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
import Vue from 'vue'
Vue.prototype.$axios = axios;

const service = axios.create({
  baseURL: 'http://127.0.0.1:3001',
  timeout: 5000 // request timeout
})
service.interceptors.request.use(
  req => {
    if (localStorage.getItem('token')) {
      req.headers['token'] = localStorage.getItem('token')
    }
    return req
  }
)

export default service



